#include "commontools.h"
#include <QDir>
#include <QDirIterator>

#include <QDebug>

CommonTools::CommonTools(QObject *parent) :
    QObject(parent)
{
}

QStringList CommonTools::ls(const QString &dir, bool directories, bool subDirectories) const
{
    QDir selectedDir(dir);
    selectedDir.setFilter(directories ? QDir::NoDot | QDir::NoDotDot | QDir::Dirs:
                                        QDir::NoDot | QDir::NoDotDot | QDir::Files | QDir::Dirs);
    if (!directories)
        selectedDir.setNameFilters(QStringList() << "*.*");
    QDirIterator it (selectedDir, subDirectories ?
                         QDirIterator::Subdirectories : QDirIterator::NoIteratorFlags);
    QStringList files;
    while (it.hasNext())
        files << it.next();
    return files;
}

void CommonTools::test(const QString &prop, const QVariant &value)
{
    qDebug() << prop << value << "COMMON";
}



